﻿<script src="~/Scripts/WebsiteControllers/NewsLetterController.js"></script>
<div class="row" ng-controller="NewsLetterController">
    <div class="search-bar collapsed">
        <div class="form-group">
            <div class="input-group input-group-lg">
                <input type="text" class="form-control" placeholder="Type to search..."  ng-model="search" ng-change="filter()" >
                <span class="input-group-btn">
                    <button class="btn btn-square btn-lg btn-default no-shadow close-search-bar" type="button"><i class="zmdi zmdi-close"></i></button>
                </span>
            </div>
        </div>
    </div>
    <div class="col-md-12">
        <div class="bg-white bs-0 mb-20 widget">
            <div role="tabpanel">
                <ul class="nav nav-pills bg-black bs-inset-primary" role="tablist">
                    <li role="presentation" class="pt-15 pb-15 pl-10 pr-20 mb-0">
                        <h3 class="fs-16 lh-1 m-0 text-white text-uppercase">News Letters List</h3>
                    </li>
                    <li class="pull-right pt-15 pb-15 pl-20 pr-10 fs-20 lh-1 mb-0">
                        <ul class="pull-right list-inline fs-16 lh-1 mb-0">
                            <li><a href="javascript:;" class="text-white" ng-click="toggle('add','')"><i class="fa fa-plus"></i></a></li>
                        </ul>
                    </li>
                </ul>
                <div class="tab-content widget-body">
                    <div class="widget-body">
                        <div class="row">
                            <div class="col-md-12">
                                <table class="table table-striped table-bordered">
                                    <thead>
                                        <th>News Letter Subject&nbsp;<a ng-click="sort_by('NewsLetterSubject');"><i class="glyphicon glyphicon-sort"></i></a></th>
                                        <th>News Letter Date&nbsp;<a ng-click="sort_by('list.ActionName');"><i class="glyphicon glyphicon-sort"></i></a></th>
                                        <th>Status &nbsp;<a ng-click="sort_by('list.ActionDescription');"><i class="glyphicon glyphicon-sort"></i></a></th>
                                        <th>Action&nbsp;<a ng-click="sort_by('list.NotifcationTemplate');"><i class="glyphicon glyphicon-sort"></i></a></th>
                                    </thead>
                                    <tbody>
                                        <tr ng-repeat="data in filtered = (list | filter:search | orderBy : predicate :reverse) | startFrom:(currentPage-1)*entryLimit | limitTo:entryLimit">
                                            <td>{{data.NewsLetterSubject}}</td>
                                            <td>{{data.CreatedOn}}</td>
                                            <td>
                                                <a ng-if="data.NewsLetterStatus==3" class="btn-sm btn-primary" ng-click="SendMail('SENDMAIL',data.NewsLetterId);">View and Send Email</a>
                                                <a ng-if="data.NewsLetterStatus==4" class="btn-sm btn-primary">Sent Email</a>
                                                @if (ViewBag.IsSuperAdmin == true)
                                                {
                                                    <a ng-if="data.NewsLetterStatus==1" ng-click="SendMail('VIEWAPPROVE',data.NewsLetterId);" class="btn-sm btn-warning">Click to View and Approve</a>
                                                }
                                                else
                                                {
                                                    <a ng-if="data.NewsLetterStatus==1" ng-click="SendMail('VIEW',data.NewsLetterId);" class="btn-sm btn-warning">Waiting for Approvel</a>
                                                }
                                            </td>
                                            <td>
                                                <div class="btn-group-sm" role="group" aria-label="Second group">
                                                    <button ng-if="data.NewsLetterStatus!=4" type="button" class="btn btn-info waves-effect" ng-click="toggle('edit',data.NewsLetterId);"><i class="fa fa-pencil"></i></button>
                                                    <button ng-if="data.NewsLetterStatus!=4" type="button" class="btn btn-danger waves-effect" ng-click="delete(data.NewsLetterSubject,data.NewsLetterId);"><i class="fa fa-trash"></i></button>
                                                </div>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                            <div class="col-md-12" ng-show="filteredItems == 0">
                                <div class="col-md-12" style="text-align: center;">
                                    <h4>No Data Available</h4>
                                </div>
                            </div>

                        </div>
                        <div ng-show="filteredItems > 0" style="padding-right: 10px; text-align: right;">
                            <div pagination="" page="currentPage" max-size="10" on-select-page="setPage(page)" boundary-links="true" total-items="filteredItems" items-per-page="entryLimit" class="pagination-small" previous-text="«" next-text="»"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade bs-example-modal-panel" tabindex="-1" id="NewsLetter" role="dialog" aria-labelledby="myPanelModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header bg-primary">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myAnimationModalLabel">{{title}}</h4>
                </div>
                <form name="fromnewsvalidate" novalidate>
                    <div class="modal-body">
                        <div class="form-group">
                            News Letter Subject
                            <input type="hidden" ng-model="Newsletter.NewsLetterId" />
                            <input type="hidden" ng-model="Newsletter.IsDeleted" />
                            <input type="hidden" ng-model="Newsletter.NewsLetterStatus" />
                            <input type="text" ng-required="true" class="form-control" ng-model="Newsletter.NewsLetterSubject">
                        </div>
                        <div class="form-group">
                            News Letter Content
                            <textarea class="form-control summernote" data-height="300" rows="10" style="width: 100%" maxlength="1000" ng-model="Newsletter.NewsLetterContent"></textarea>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                        <button type="button" class="btn btn-primary" ng-disabled="fromnewsvalidate.$invalid" ng-click="save(modelstate)">Save</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="modal fade bs-example-modal-panel" tabindex="-1" id="Mail" role="dialog" aria-labelledby="myPanelModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header bg-primary">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myAnimationModalLabel1">{{title}}</h4>
                </div>
                <form name="fromnewsvalidate" novalidate>
                    <div class="modal-body">
                        <div class="form-group">
                            News Letter Subject
                            <input type="hidden" ng-model="Newsletter.NewsLetterId" />
                            <input type="hidden" ng-model="Newsletter.IsDeleted" />
                            <input type="hidden" ng-model="Newsletter.NewsLetterStatus" />
                            <span ng-bind="Newsletter.NewsLetterSubject"></span>
                        </div>
                        <div class="form-group">
                            News Letter Content
                            <span ng-bind="Newsletter.NewsLetterContent"></span>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                        <button type="button" class="btn btn-primary" ng-click="ApproveRejectNewsLetter(3)" ng-if="sendstatus=='VIEWAPPROVE'">Approve</button>
                        <button type="button" class="btn btn-primary" ng-click="ApproveRejectNewsLetter(-1)" ng-if="sendstatus=='VIEWAPPROVE'">Reject</button>
                        <button type="button" class="btn btn-primary" ng-click="SendNewsletters()" ng-if="sendstatus=='SENDMAIL'">Send Mail</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
